package comparators;

import java.util.Comparator;

import bookworm.BooksAndRatingOfOneAuthor;

public class ComparatorOfBooksAndAverareRating implements Comparator<Object>
{

	@Override
	public int compare(Object arg0, Object arg1) 
	{
		 BooksAndRatingOfOneAuthor booksAndRating0 =
				 (BooksAndRatingOfOneAuthor) arg0;
		 BooksAndRatingOfOneAuthor booksAndRating1 =
				 (BooksAndRatingOfOneAuthor) arg1;
		 int ratingBooksAndRating0 = booksAndRating0.getAverageRatingOfAuthorBasedOnTag();
		 int ratingBooksAndRating1 = booksAndRating1.getAverageRatingOfAuthorBasedOnTag();
		 
		 if(ratingBooksAndRating0 > ratingBooksAndRating1)
		 {
			 return -1;
		 }
		 else if (ratingBooksAndRating0 == ratingBooksAndRating1)
		 {
			 return 0;
		 }
		 else
		 {
			 return 1;
		 }
	}

}
